<template>
  <el-form rules="FormRules" ref="form" :model="loginForm">
    <div class="wrap">
      <div class="form">
        <div class="left">
          <video src="../assets/video.mp4" muted loop autoplay></video>
        </div>
        <div class="right">
          <div class="right-con">
            <h1>WELCOME</h1>
            <h3>NAME</h3>
            <input class="text" type="text" v-model="loginForm.username" />
            <h3>EMAIL</h3>
            <input class="text" type="text" v-model="loginForm.email"/>
            <h3>PASSWORD</h3>
            <input class="text" type="password" v-model="loginForm.password"/>
            <input class="btn" type="button" value="LOGIN" @click="submitToLogin"/>
          </div>
        </div>
      </div>
    </div>
  </el-form>
</template>

<script>
import { postRequest } from "../utils/api";
export default {
  name: "GoLogin",
  data(){
      return{
          loginForm:{
              username:'Dylan',
              email:'1589842555@qq.com',
              password:'12345'
          }
      }
  },
  methods:{
      submitToLogin(){
         if(this.loginForm.username==""||this.loginForm.email==""||this.loginForm.password==""){
            this.$message.error("finish your individual information please");
         }else{
           postRequest("/user/goLogin", this.loginForm).then((resp) => {
              if (resp) {
                const token = resp.data.token;
                const user = resp.data.user;
                window.sessionStorage.setItem('token',token);
                window.sessionStorage.setItem('user',JSON.stringify(user));
                // 跳轉首頁
                let path = this.$route.query.redirect;
                this.$router.replace((path=='/'||path==undefined)?'/myHome':path)
              }
            });
         }
      }, 
  }
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  overflow: hidden;
}

.wrap {
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-image: linear-gradient(
    to left top,
    #d16ba5,
    #c777b9,
    #ba83ca,
    #aa8fd8,
    #9a9ae1,
    #8aa7ec,
    #79b3f4,
    #69bff8,
    #52cffe,
    #41dfff,
    #46eefa,
    #5ffbf1
  );
}

.form {
  width: 900px;
  height: 560px;
  display: flex;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 25px 45px rgba(0, 0, 0, 0.1);
}

.left {
  width: 500px;
  height: 560px;
}

.left video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.right {
  width: 400px;
  height: 560px;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
}

.right-con {
  width: 70%;
  display: flex;
  flex-direction: column;
  text-align: center;
}

h1 {
  font-size: 36px;
  font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif;
  color: #70b4e3;
  font-weight: 400;
  padding-bottom: 10px;
}

h3 {
  font-size: 12px;
  font-weight: 400;
  color: #70b4e3;
  padding: 20px 0;
}

.text {
  width: 100%;
  outline: none;
  border: none;
  border-bottom: 1px solid #70b4e3;
  color: #366ae6;
  background-color: rgba(0, 0, 0, 0);
}

.btn {
  width: 100%;
  height: 40px;
  border-radius: 20px;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  margin-top: 50px;
  background-image: linear-gradient(120deg, #76daec 0%, #c5a8de 100%);
}

.btn:hover {
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}
</style>>


